﻿using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;

namespace bpms.Models
{
    /// <summary>
    /// 订单
    /// </summary>
    [Table("Order")]
    public class Order
    {
        [Key]
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public int Id { get; set; }

        [StringLength(50)]
        [Display(Name = "订单编号")]
        [Required(ErrorMessage = "订单编号不能为空")]
        [Column("order_no")]
        public string OrderNo { get; set; }

        [Display(Name = "总金额")]
        [Column("total_amount",TypeName = "decimal(10,2)")]
        public decimal TotalAmount { get; set; }

        [Display(Name = "配送时间")]
        [Column("delivery_time")]
        public DateTime DeliveryTime { get; set; }

        [Display(Name = "数量")]
        [Required(ErrorMessage = "数量不能为空")]
        [Range(0, int.MaxValue, ErrorMessage = "数量必须大于0")]
        [Column("quantity")]
        public int Quantity { get; set; }

        [Display(Name = "饮品")]
        [Column("product_id")]
        public int ProductID { get; set; }

        [Display(Name = "顾客ID")]
        [Column("customer_id")]
        public int CustomerID { get; set; }

        [Display(Name = "下单时间")]
        public DateTime CreatedTime { get; set; }
    }
}
